﻿'Imports Microsoft.VisualBasic
'Imports System
'Public Class GlobalMembersPi
'#If _MSC_VER > 1000 Then
'#End If

'    'C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
'    'ORIGINAL LINE: #define VC_EXTRALEAN
'#Const VC_EXTRALEAN = True

'#If Not _AFX_NO_AFXCMN_SUPPORT Then
'#End If


'    ' TODO: reference additional headers your program requires here

'    '{{AFX_INSERT_LOCATION}}
'    ' Microsoft Visual C++ will insert additional declarations immediately before the previous line.



'    ' TODO: reference any additional headers you need in STDAFX.H
'    ' and not in this file

'#Const IDS_HELLO = True

'    ' Next default values for new objects
'    ' 
'#If APSTUDIO_INVOKED Then
'#If Not APSTUDIO_READONLY_SYMBOLS Then
'#Const _APS_NEXT_RESOURCE_VALUE = True
'#Const _APS_NEXT_COMMAND_VALUE = True
'#Const _APS_NEXT_CONTROL_VALUE = True
'#Const _APS_NEXT_SYMED_VALUE = True
'#End If
'#End If




'#If DEBUG Then
'    'C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
'    'ORIGINAL LINE: #define new DEBUG_NEW
'    '	#Const new = True
'    'C++ TO VB CONVERTER TODO TASK: There is no equivalent to #undef in VB:
'    '#undef THIS_FILE
'    'C++ TO VB CONVERTER TODO TASK: There is no direct equivalent in VB to the following C++ macro:
'    '    Friend Shared THIS_FILE As String = __FILE__
'#End If

'    '///////////////////////////////////////////////////////////////////////////

'#If _MSC_VER > 1000 Then
'#End If

'    '///////////////////////////////////////////////////////////////////////////
'    ' The one and only application object

'    ' Public Shared theApp As New CWinApp()


'    Public Shared Function _tmain(ByVal argc As Integer, ByRef argv() As String, ByRef envp() As String) As Integer
'        Dim nRetCode As Integer = 0

'        ' initialize MFC and print and error on failure
'        If 1 = 0 Then
'            ' TODO: change error code to suit your needs
'            'cerr << "Fatal Error: MFC initialization failed" << ControlChars.Lf
'            nRetCode = 1
'        Else
'            ' TODO: code your application's behavior here.
'            'CRH CString strHello;
'            'CRH strHello.LoadString(IDS_HELLO);
'            'CRH cout << (LPCTSTR)strHello << endl;

'            CRHCalculatePiClass.CRHCalculatePi()
'        End If

'        Return nRetCode
'    End Function
'End Class

'' pi.cpp : Defines the entry point for the console application.
''

'#If _MSC_VER > 1000 Then
'#End If
''C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
''ORIGINAL LINE: #define VC_EXTRALEAN
'#Const VC_EXTRALEAN = True
'#If Not _AFX_NO_AFXCMN_SUPPORT Then
'#End If


'#If _MSC_VER > 1000 Then
'#End If



'Public Class GlobalMembersCRHMultiLengthInteger



'#If DEBUG Then
'    'C++ TO VB CONVERTER TODO TASK: There is no equivalent to #undef in VB:
'    '#undef THIS_FILE
'    'C++ TO VB CONVERTER TODO TASK: There is no direct equivalent in VB to the following C++ macro:
'    'Friend Shared THIS_FILE As String = __FILE__
'    'C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
'    'ORIGINAL LINE: #define new DEBUG_NEW
'    '#Const new = True
'#End If
'End Class

'' CRHMultiLengthInteger.cpp: implementation of the CRHMultiLengthInteger class.
''
''////////////////////////////////////////////////////////////////////

'#If _MSC_VER > 1000 Then
'#End If
''C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
''ORIGINAL LINE: #define VC_EXTRALEAN
'#Const VC_EXTRALEAN = True
'#If Not _AFX_NO_AFXCMN_SUPPORT Then
'#End If
'#If _MSC_VER > 1000 Then
'#End If
'' CRHMultiLengthInteger.h: interface for the CRHMultiLengthInteger class.
''
''////////////////////////////////////////////////////////////////////


'#If _MSC_VER > 1000 Then
'#End If

'#Const NDecimalPlaces = True

'#Const MaxElementValuePlus1 = True
'#Const NDigits = True
''C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
''ORIGINAL LINE: #define NElements (1 + (NDecimalPlaces+5)/6)
'#Const NElements = True

'Public Class CRHMultiLengthInteger

'    '////////////////////////////////////////////////////////////////////
'    ' Construction/Destruction
'    '////////////////////////////////////////////////////////////////////

'    Public Sub New()
'        Dim sum As Integer = 1 + (DefineConstants.NDecimalPlaces + 5) / 6
'        Dim iDef(sum) As Integer ' [0] is the most significant element
'        i = iDef
'    End Sub
'    Public Overridable Sub Dispose()

'    End Sub

'    'C++ TO VB CONVERTER NOTE: This 'CopyFrom' method was converted from the original C++ copy assignment operator:
'    'ORIGINAL LINE: void operator =(Integer const val)
'    Public Sub CopyFrom(ByVal val As Integer)
'        assign(val)
'    End Sub
'    'C++ TO VB CONVERTER TODO TASK: The += operator cannot be overloaded in VB:
'		Public Shared Sub Operator +=(ByVal delta As CRHMultiLengthInteger)
'        addfunc(delta)
'    End Sub
'    'C++ TO VB CONVERTER TODO TASK: The -= operator cannot be overloaded in VB:
'		Public Shared Sub Operator -=(ByVal delta As CRHMultiLengthInteger)
'        subfunc(delta)
'    End Sub
'    'C++ TO VB CONVERTER TODO TASK: The /= operator cannot be overloaded in VB:
'		Public Shared Sub Operator /=(ByVal divisor As UInteger)
'        divfunc(divisor)
'    End Sub
'    'C++ TO VB CONVERTER WARNING: 'const' methods are not available in VB:
'    'ORIGINAL LINE: Boolean operator >(CRHMultiLengthInteger const & b) const
'    Public Shared Operator >(ByVal ImpliedObject As CRHMultiLengthInteger, ByVal b As CRHMultiLengthInteger) As Boolean
'        Return (compop(b) > 0)
'    End Operator
'    'C++ TO VB CONVERTER WARNING: 'const' methods are not available in VB:
'    'ORIGINAL LINE: Boolean operator ==(CRHMultiLengthInteger const & b) const
'    Public Shared Operator =(ByVal ImpliedObject As CRHMultiLengthInteger, ByVal b As CRHMultiLengthInteger) As Boolean
'        Return (compop(b) = 0)
'    End Operator
'    'C++ TO VB CONVERTER WARNING: 'const' methods are not available in VB:
'    'ORIGINAL LINE: String ToCString() const
'    Public Function ToCString() As String
'        Dim s As String = ""
'        Dim p As String = ""

'        For j As Integer = 0 To 1 + (DefineConstants.NDecimalPlaces + 5) / 6 - 1
'            Dim k As Integer = i(j)

'            If j = 0 Then
'                p = k.ToString & "."
'                'p.Format(" %"DefineConstants.NDigits"d.", k)
'            Else
'                p = k.ToString
'                'p.Format(" %0"DefineConstants.NDigits"d", k)
'            End If

'            s &= p

'            If (j Mod 10) = 0 Then
'                s &= vbLf
'            End If
'        Next j

'        Return (s)
'    End Function

'    Private Sub assign(ByVal val As Integer)
'        Dim Asuperlong As CRHMultiLengthInteger = Me
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim Ai As Integer

'        Ai = Asuperlong.i(0)
'        Do While Ai < Asuperlong.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6)
'            Ai = 0
'            Ai += 1
'        Loop
'        Asuperlong.i(0) = val
'    End Sub

'    '////////////////////////////////////////////////////////////////////

'    Private Sub addfunc(ByVal Adelta As CRHMultiLengthInteger)
'        Dim Alv As CRHMultiLengthInteger = Me
'        Dim Ai As Integer
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim Ad As Integer
'        Dim j As Integer

'        j = 0
'        Ai = Alv.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6 - 1)
'        Ad = Adelta.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6 - 1)
'        Do While j < 1 + (DefineConstants.NDecimalPlaces + 5) / 6
'            Ai += Ad
'            If Ai >= DefineConstants.MaxElementValuePlus1 Then
'                Ai -= DefineConstants.MaxElementValuePlus1
'                If Ai <= Alv.i(0) Then
'                    [error]() ' overflow
'                End If
'                Ai += 1
'            End If
'            j += 1
'            Ai -= 1
'            Ad -= 1
'        Loop
'    End Sub
'    Private Sub subfunc(ByVal Adelta As CRHMultiLengthInteger)
'        Dim Alv As CRHMultiLengthInteger = Me
'        Dim Ai As Integer
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim Ad As Integer
'        Dim j As Integer

'        j = 0
'        Ai = Alv.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6 - 1)
'        Ad = Adelta.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6 - 1)
'        Do While j < 1 + (DefineConstants.NDecimalPlaces + 5) / 6
'            Ai -= Ad
'            If Ai < 0 Then
'                Ai += DefineConstants.MaxElementValuePlus1
'                If Ai <= Alv.i(0) Then
'                    [error]() ' overflow
'                End If
'                Ai -= 1
'            End If
'            j += 1
'            Ai -= 1
'            Ad -= 1
'        Loop
'    End Sub
'    'C++ TO VB CONVERTER WARNING: 'const' methods are not available in VB:
'    'ORIGINAL LINE: Integer compop(CRHMultiLengthInteger const *Ab) const
'    'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on the parameter 'Ab', so pointers on this parameter are left unchanged:
'    Private Function compop(ByVal Ab As CRHMultiLengthInteger) As Integer
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        'C++ TO VB CONVERTER WARNING: The following line was determined to be a copy constructor call - this should be verified and a copy constructor should be created if it does not yet exist:
'        'ORIGINAL LINE: CRHMultiLengthInteger const *Aa = this;
'        Dim Aa As CRHMultiLengthInteger = New CRHMultiLengthInteger()
'        Aa = Me
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim lAa As Integer
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim lAb As Integer

'        lAa = Aa.i(0)
'        lAb = Ab.i(0)
'        Do While lAa < Aa.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6) ' high to low
'            If lAa <> lAb Then
'                Return (lAa - lAb)
'            End If
'            lAa += 1
'            lAb += 1
'        Loop
'        Return (0)
'    End Function
'    Private Sub divfunc(ByVal divisor As UInteger)
'        Dim Alv As CRHMultiLengthInteger = Me
'        'C++ TO VB CONVERTER TODO TASK: Pointer arithmetic is detected on this variable, so pointers on this variable are left unchanged:
'        Dim Ai As Integer
'        Dim d As Long

'        Ai = Alv.i(0)
'        d = 0
'        Do While Ai < Alv.i(1 + (DefineConstants.NDecimalPlaces + 5) / 6) ' high to low
'            d += Ai
'            Ai = d \ divisor
'            d = (d Mod divisor) * DefineConstants.MaxElementValuePlus1
'            If d < 0 Then
'                [error]()
'            End If
'            Ai += 1
'        Loop
'    End Sub

'    'C++ TO VB CONVERTER WARNING: 'const' methods are not available in VB:
'    'ORIGINAL LINE: void error() const
'    Private Sub [error]()
'        Console.Write(vbLf & "Error" & vbLf)
'        Environment.Exit(4)
'    End Sub

'    Public f As Integer()

'    'C++ TO VB CONVERTER TODO TASK: The following statement was not recognized, possibly due to an unrecognized macro:
'    Public i As Integer()
'End Class


'Public Class GlobalMembersCRHCalculatePiClass



'#If DEBUG Then
'    'C++ TO VB CONVERTER TODO TASK: There is no equivalent to #undef in VB:
'    '#undef THIS_FILE
'    'C++ TO VB CONVERTER TODO TASK: There is no direct equivalent in VB to the following C++ macro:
'    'Friend Shared THIS_FILE As String = __FILE__
'    'C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
'    'ORIGINAL LINE: #define new DEBUG_NEW
'    '#Const new = True
'#End If

'    '////////////////////////////////////////////////////////////////////


'#If _MSC_VER > 1000 Then
'#End If
'#Const NDecimalPlaces = True
'#Const MaxElementValuePlus1 = True
'#Const NDigits = True
'    'C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
'    'ORIGINAL LINE: #define NElements (1 + (NDecimalPlaces+5)/6)
'#Const NElements = True

'    Public Shared answer As New CRHMultiLengthInteger()
'    Public Shared zero As New CRHMultiLengthInteger()
'    Public Shared term5 As New CRHMultiLengthInteger()
'    Public Shared term239 As New CRHMultiLengthInteger()
'    Public Shared term5m As New CRHMultiLengthInteger()
'    Public Shared term239m As New CRHMultiLengthInteger()
'    Public Shared n5 As Integer
'    Public Shared n239 As Integer

'    'Public Shared ResultFile As New CStdioFile()

'    '////////////////////////////////////////////////////////////////////
'    ' Construction/Destruction
'    '////////////////////////////////////////////////////////////////////

'    'Public Shared Function ftimediff(ByVal pTimeA As timeb, ByVal pTimeB As timeb) As UInteger
'    '    Return ((1000 * pTimeA.time + pTimeA.millitm) - (1000 * pTimeB.time + pTimeB.millitm))
'    'End Function
'End Class

'' CRHCalculatePiClass.cpp: implementation of the CRHCalculatePiClass class.
''
''////////////////////////////////////////////////////////////////////

'#If _MSC_VER > 1000 Then
'#End If
''C++ TO VB CONVERTER NOTE: The following #define macro was replaced in-line:
''ORIGINAL LINE: #define VC_EXTRALEAN
'#Const VC_EXTRALEAN = True
'#If Not _AFX_NO_AFXCMN_SUPPORT Then
'#End If
'#If _MSC_VER > 1000 Then
'#End If
'' CRHCalculatePiClass.h: interface for the CRHCalculatePiClass class.
''
''////////////////////////////////////////////////////////////////////


'#If _MSC_VER > 1000 Then
'#End If

'Public Class CRHCalculatePiClass
'    'CRHCalculatePiClass();
'    'virtual ~CRHCalculatePiClass();

'    ' vvv CRH

'    Private Shared Sub dispresult()
'        Dim r As String = GlobalMembersCRHCalculatePiClass.answer.ToCString()
'        Console.Write(r)
'    End Sub
'    Private Shared Sub do239term()
'        'C++ TO VB CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
'        'ORIGINAL LINE: term239m = term239;
'        GlobalMembersCRHCalculatePiClass.term239m.CopyFrom(GlobalMembersCRHCalculatePiClass.term239)
'        GlobalMembersCRHCalculatePiClass.term239m /= GlobalMembersCRHCalculatePiClass.n239 * 2 + 1
'        If GlobalMembersCRHCalculatePiClass.n239 Mod 2 = 0 Then
'            GlobalMembersCRHCalculatePiClass.answer -= GlobalMembersCRHCalculatePiClass.term239m ' n239 is even
'        Else
'            GlobalMembersCRHCalculatePiClass.answer += GlobalMembersCRHCalculatePiClass.term239m ' n239 is odd
'        End If
'        GlobalMembersCRHCalculatePiClass.term239 /= 239 * 239
'        GlobalMembersCRHCalculatePiClass.n239 += 1
'    End Sub
'    Private Shared Sub do5term()
'        'C++ TO VB CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
'        'ORIGINAL LINE: term5m = term5;
'        GlobalMembersCRHCalculatePiClass.term5m.CopyFrom(GlobalMembersCRHCalculatePiClass.term5)
'        GlobalMembersCRHCalculatePiClass.term5m /= GlobalMembersCRHCalculatePiClass.n5 * 2 + 1
'        If GlobalMembersCRHCalculatePiClass.n5 Mod 2 = 0 Then
'            GlobalMembersCRHCalculatePiClass.answer += GlobalMembersCRHCalculatePiClass.term5m ' n5 is even
'        Else
'            GlobalMembersCRHCalculatePiClass.answer -= GlobalMembersCRHCalculatePiClass.term5m ' n5 is odd
'        End If
'        GlobalMembersCRHCalculatePiClass.term5 /= 5 * 5
'        GlobalMembersCRHCalculatePiClass.n5 += 1
'    End Sub
'    Private Shared Sub calculate()
'        Do
'            do5term()
'            If GlobalMembersCRHCalculatePiClass.term5m Is GlobalMembersCRHCalculatePiClass.zero Then
'                Exit Do
'            End If
'        Loop

'        Do
'            do239term()
'            If GlobalMembersCRHCalculatePiClass.term239m Is GlobalMembersCRHCalculatePiClass.zero Then
'                Exit Do
'            End If
'        Loop
'    End Sub
'    Private Shared Sub init()
'        GlobalMembersCRHCalculatePiClass.term5 = 16
'        GlobalMembersCRHCalculatePiClass.term5 /= 5
'        GlobalMembersCRHCalculatePiClass.n5 = 0

'        GlobalMembersCRHCalculatePiClass.term239 = 4
'        GlobalMembersCRHCalculatePiClass.term239 /= 239
'        GlobalMembersCRHCalculatePiClass.n239 = 0

'        GlobalMembersCRHCalculatePiClass.answer = 0
'        GlobalMembersCRHCalculatePiClass.zero = 0
'    End Sub

'    Public Shared Sub CRHCalculatePi()
'        'Dim StartTime As New timeb()
'        'Dim EndTime As New timeb()
'        'ftime(StartTime)

'        init()
'        calculate()

'        '      ftime(EndTime)

'        '      Dim Filename As String
'        '      Filename.Format("result%i.txt", DefineConstants.NDecimalPlaces)
'        '      GlobalMembersCRHCalculatePiClass.ResultFile.Open(Filename, CFile.modeCreate Or CFile.modeWrite Or CFile.modeNoInherit Or CFile.shareExclusive)
'        'GlobalMembersCRHCalculatePiClass.ResultFile.WriteString(" pi is approximately" vbLf & vbLf)
'        dispresult()

'        '      Dim NMilliseconds As UInteger = GlobalMembersCRHCalculatePiClass.ftimediff(EndTime, StartTime)
'        '      Dim TimeInfo As String
'        'TimeInfo.Format(vbLf & vbLf " Time taken is %i.%03i seconds", NMilliseconds \ 1000, NMilliseconds Mod 1000)
'        '      GlobalMembersCRHCalculatePiClass.ResultFile.WriteString(TimeInfo)
'    End Sub

'    ' ^^^ CRH
'End Class


'Partial Friend NotInheritable Class DefineConstants
'    Public Const NDecimalPlaces As Integer = 1000100
'    Public Const MaxElementValuePlus1 As Integer = 1000000
'    Public Const NDigits As String = "6"
'    Public Const IDS_HELLO As Integer = 1
'    Public Const _APS_NEXT_RESOURCE_VALUE As Integer = 101
'    Public Const _APS_NEXT_COMMAND_VALUE As Integer = 40001
'    Public Const _APS_NEXT_CONTROL_VALUE As Integer = 1000
'    Public Const _APS_NEXT_SYMED_VALUE As Integer = 101
'End Class